'''
This file is part of ModeliMark.

ModeliMark is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.

ModeliMark is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with ModeliMark.
If not, see <http://www.gnu.org/licenses/>.

Copyright 2012 Jens Frenkel
'''

import os

class LoadResultFile(object):
    '''
    classdocs
    '''


    def __init__(self, path):
        '''
        Constructor
        '''
        assert(isinstance(path,str))
        self._path = path

        f = open( self._path, 'r' )

        self.open = (list(), list())
        self.flatten = (list(), list())
        self.translate = (list(), list())
        self.simulate = (list(), list())
        self.header = (list(), list())

        header = True
        for line in f:
            print line
            if (header):
                l = list()
                item = line.split(';')
                for i in item:
                    if (not i == '\n'):
                        i = i.replace('\n','')
                        l.append(i)
                self.header = l
                header = False
            else:
                item = line.split(';')
                l = list()
                for i in item:
                    if (not i == '\n'):
                        i = i.replace('\n','')
                        l.append(i)
                try:
                    n = float(l[0].replace(' ',''))
                except Exception, e:
                    n = l[0]
                if (len(l)>1):
                    if not((l[1] == 'NONE') or (l[1] == '')):
                        self.open[0].append(n)
                        self.open[1].append(float(l[1]))
                if (len(l)>2):
                    if not((l[2] == 'NONE') or (l[2] == '')):
                        self.flatten[0].append(n)
                        self.flatten[1].append(float(l[2]))
                if (len(l)>3):
                    if not((l[3] == 'NONE') or (l[3] == '')):
                        self.translate[0].append(n)
                        self.translate[1].append(float(l[3]))
                if (len(l)>4):
                    if not((l[4] == 'NONE') or (l[4] == '')):
                        self.simulate[0].append(n)
                        self.simulate[1].append(float(l[4]))

        f.close()
